package com._101aiot.common.resultutil;

/**
 * 状态码枚举
 * <p>
 * 常见的 http 状态码
 * 200 - 请求成功
 * 301 - 资源（网页等）被永久转移到其它URL
 * 404 - 请求的资源（网页等）不存在
 * 500 - 内部服务器错误
 * <p>
 * <p>
 * #10000～19999 区间表示参数错误
 * #20000～29999 区间表示用户错误
 * #30000～39999 区间表示接口异常
 * #99999 额外异常-远程调用失败，异常无响应等等
 * @author xiongguodong.
 */
public enum ResultCode implements IResultCode {

    /* 常见状态码 */
    SUCCESS(true, "00000", "操作成功！"),
    SUCCESS_NO_DATA(false, "00001", "未查询到数据！"),
    RESOURCES_PERMANENTLY_TRANSFERRED(false, "301", "资源（网页等）被永久转移到其它URL！"),
    BUSINESS_FAILURE(false, "400", "业务异常！"),
    UNAUTHORIZED(false, "401", "暂未登录或token已经过期！"),
    FORBIDDEN(false, "403", "没有相关权限！"),
    VALIDATE_FAILED(false, "404", "请求的资源（网页等）不存在！"),
    FAILED(false, "500", "内部服务器错误！"),

    /* 10000～19999 区间表示参数错误 */
    PARAMETER_CHECK_FAILED(false, "10000", "请求参数不正确！"),
    INVALID_PARAM(false, "10001", "非法参数！"),
    PARAM_IS_INVALID(false, "10002", "参数无效！"),
    PARAM_CHECK_EXCEPTION(false, "10003", "参数绑定校验异常！"),

    /* 20000～29999 区间表示用户错误 */
//    AUTH_USERNAME_NONE(false, "20000", "请输入账号！"),
    AUTH_PASSWORD_NONE(false, "20001", "请输入密码！"),
    AUTH_VERIFY_CODE_NONE(false, "20002", "请输入验证码！"),
//    AUTH_ACCOUNT_NOT_EXISTS(false, "20003", "账号不存在！"),
//    AUTH_CREDENTIAL_ERROR(false, "20004", "账号或密码错误！"),
    UNAUTHENTICATED(false, "20005", "此操作需要登陆系统！"),
    UNAUTHORISE(false, "20006", "权限不足，无权操作！"),

    /* 30000～39999 区间表示接口异常 */
    AUTH_LOGIN_ERROR(false, "30000", "登陆过程出现异常，请尝试重新操作！"),
//    AUTH_LOGIN_APPLY_TOKEN_FAIL(false, "30001", "申请令牌失败！"),
//    AUTH_LOGIN_TOKEN_SAVE_FAIL(false, "30002", "存储令牌失败！"),

    /* 额外异常 */
    SERVER_ERROR(false, "99999", "抱歉，系统繁忙，请稍后重试！");

    private final boolean success;

    private final String code;

    private final String message;

    ResultCode(boolean success, String code, String message) {
        this.success = success;
        this.code = code;
        this.message = message;
    }

    public String getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }

    public boolean getSuccess() {
        return success;
    }
}
